package com.tsj.spzx.user.controller;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.tsj.spzx.model.vo.common.Result;
import com.tsj.spzx.model.vo.common.ResultCodeEnum;
import com.tsj.spzx.user.service.SMessageService;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("api/user/sms")
@Tag(name="短信接口")
public class SMessageController {

    @Autowired
    private SMessageService sMessageService;

    /**
     * 发送短信验证码
     * @param phone
     * @return
     */
    @GetMapping(value = "/sendCode/{phone}")
    public Result sendMessage(@PathVariable("phone") String phone) throws JsonProcessingException {
        sMessageService.sendMessage(phone);
        return Result.build(null, ResultCodeEnum.SUCCESS);
    }
}
